package cc.admin.common.db.table.base;

import cn.hutool.db.DbUtil;
import org.springframework.jdbc.core.JdbcTemplate;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
/**
 * @author: ZhangHouYing
 * @date: 2021-09-22 14:23
 */
public class BaseEtl {

	/**
	 * 获取数据库类型
	 *
	 * @param jdbcTemplate
	 * @return
	 */
	public static String getDatabaseProductName(JdbcTemplate jdbcTemplate) {
		String databaseProductName = null;
		Connection connection = null;
		try {
			connection = jdbcTemplate.getDataSource().getConnection();
			DatabaseMetaData md = connection.getMetaData();
			databaseProductName = md.getDatabaseProductName();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DbUtil.close(connection);
		}
		return databaseProductName;
	}

}
